<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="keywords" content="Hexo Theme Redefine">
    <meta name="description" content="记录美好生活">
    <meta name="author" content="Sun-dingyang">
    
    <title>
        
        Sun-dingyang
    </title>
    
<link rel="stylesheet" href="/css/style.css">

    <link rel="shortcut icon" href="/images/logo.svg">
    
<link rel="stylesheet" href="/css/fontawesome.min.css">

    
<link rel="stylesheet" href="/css/v5-font-face.min.css">

    
<link rel="stylesheet" href="/css/duotone.min.css">

    
<link rel="stylesheet" href="/css/brands.min.css">

    
<link rel="stylesheet" href="/css/solid.min.css">

    
<link rel="stylesheet" href="/css/css2.css">

    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <script id="hexo-configurations">
    let REDEFINE = window.REDEFINE || {};
    REDEFINE.hexo_config = {"hostname":"example.com","root":"/","language":"zh_CN"};
    REDEFINE.theme_config = {"toc":{"enable":true,"number":false,"expand_all":true,"init_open":true},"style":{"primary_color":"#005080","avatar":"/images/avatar.svg","favicon":"/images/logo.svg","article_img_align":"center","right_side_width":"210px","content_max_width":"1000px","nav_color":{"left":"#f78736","right":"#367df7","transparency":35},"hover":{"shadow":true,"scale":false},"first_screen":{"enable":true,"background_image":{"light":"https://evan.beee.top/img/wallhaven-wqery6-light.webp","dark":"https://evan.beee.top/img/wallhaven-wqery6-dark.webp"},"title_color":{"light":"#fff","dark":"#d1d1b6"},"description":"张若曦是头猪"},"scroll":{"progress_bar":{"enable":true},"percent":{"enable":false}}},"local_search":{"enable":false,"preload":true},"code_copy":{"enable":true},"pjax":{"enable":true},"lazyload":{"enable":true},"version":"0.3.5"};
    REDEFINE.language_ago = {"second":"%s seconds ago","minute":"%s minutes ago","hour":"%s hours ago","day":"%s days ago","week":"%s weeks ago","month":"%s months ago","year":"%s years ago"};
  </script>
<meta name="generator" content="Hexo 6.3.0"></head>


<body>
<div class="progress-bar-container">
    
        <span class="scroll-progress-bar"></span>
    

    
        <span class="pjax-progress-bar"></span>
        <span class="pjax-progress-icon">
            <i class="fas fa-circle-notch fa-spin"></i>
        </span>
    
</div>


<main class="page-container">

    

    <div class="page-main-content">

        <div class="page-main-content-top">
            <header class="header-wrapper">
    
    <div class="header-content">
        <div class="left">
            
            <a class="logo-title" href="/">
                Sun-dingyang
            </a>
        </div>

        <div class="right">
            <div class="pc">
                <ul class="menu-list">
                    
                        <li class="menu-item">
                            <a class=""
                               href="/"
                            >
                                HOME
                            </a>
                        </li>
                    
                        <li class="menu-item">
                            <a class=""
                               href="/archives"
                            >
                                ARCHIVES
                            </a>
                        </li>
                    
                    
                </ul>
            </div>
            <div class="mobile">
                
                <div class="icon-item menu-bar">
                    <div class="menu-bar-middle"></div>
                </div>
            </div>
        </div>
    </div>

    <div class="header-drawer">
        <ul class="drawer-menu-list">
            
                <li class="drawer-menu-item flex-center">
                    <a class=""
                       href="/">HOME</a>
                </li>
            
                <li class="drawer-menu-item flex-center">
                    <a class=""
                       href="/archives">ARCHIVES</a>
                </li>
            
        </ul>
    </div>

    <div class="window-mask"></div>

</header>


        </div>

        <div class="page-main-content-middle">

            <div class="main-content">

                
                    <div class="fade-in-down-animation">
    <div class="post-page-container">
        <div class="article-content-container">
            <div class="article-title">
                <span class="title-hover-animation"><h1 style="font-size:2rem; font-weight: bold; margin: 10px 0;"></h1></span>
            </div>

            
                <div class="article-header">
                    <div class="avatar">
                        <img src="/images/avatar.svg">
                    </div>
                    <div class="info">
                        <div class="author">
                            <span class="name">Sun-dingyang</span>
                            
                                <span class="author-label">lol</span>
                            
                        </div>
                        <div class="meta-info">
                            <div class="article-meta-info">
    <span class="article-date article-meta-item">
        <i class="fa-duotone fa-pen-line"></i>&nbsp;
        <span class="pc">2022-12-13 15:59:18</span>
        <span class="mobile">2022-12-13 15:59</span>
    </span>
    
    

    
    
    
    
        <span class="article-pv article-meta-item">
            <i class="fas fa-eye"></i>&nbsp;<span id="busuanzi_value_page_pv"></span>
        </span>
    
</div>

                        </div>
                    </div>
                </div>
            

            <div class="article-content markdown-body">
                <hr>
<hr>
<h1 id="Git使用"><a href="#Git使用" class="headerlink" title="Git使用"></a>Git使用</h1><h2 id="一、git介绍"><a href="#一、git介绍" class="headerlink" title="一、git介绍"></a>一、git介绍</h2><h3 id="1、版本控制工具"><a href="#1、版本控制工具" class="headerlink" title="1、版本控制工具"></a>1、版本控制工具</h3><p>（1）作用：</p>
<p>​				代码存储</p>
<p>​				代码版本管理</p>
<p>​				团队开发</p>
<p>（2）设计者</p>
<p>​				linux之父</p>
<h3 id="2、git和svn"><a href="#2、git和svn" class="headerlink" title="2、git和svn"></a>2、git和svn</h3><p>（1）git</p>
<p>分布式的版本控制工具</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020111853885.png"
                      alt="image-20211020111853885"
                ></p>
<p>（2）svn(自学)</p>
<p>集中式的版本控制工具</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020111559396.png"
                      alt="image-20211020111559396"
                ></p>
<h2 id="二、git安装"><a href="#二、git安装" class="headerlink" title="二、git安装"></a>二、git安装</h2><h3 id="1、下载"><a href="#1、下载" class="headerlink" title="1、下载"></a>1、下载</h3><p><a class="link"   target="_blank" rel="noopener" href="https://git-scm.com/" >https://git-scm.com/<i class="fas fa-external-link-alt"></i></a></p>
<p><a class="link"   target="_blank" rel="noopener" href="https://github.com/git-for-windows/git/releases/download/v2.33.1.windows.1/Git-2.33.1-64-bit.exe" >https://github.com/git-for-windows/git/releases/download/v2.33.1.windows.1/Git-2.33.1-64-bit.exe<i class="fas fa-external-link-alt"></i></a></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020113345712.png"
                      alt="image-20211020113345712"
                ></p>
<h3 id="2、安装"><a href="#2、安装" class="headerlink" title="2、安装"></a>2、安装</h3><p>无脑next</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020113750834.png"
                      alt="image-20211020113750834"
                ></p>
<h3 id="3、测试"><a href="#3、测试" class="headerlink" title="3、测试"></a>3、测试</h3><p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/0U%7B%60%5BWL3YS0825GDUIND%5DMV.png"
                      alt="img"
                ></p>
<h2 id="三、配置"><a href="#三、配置" class="headerlink" title="三、配置"></a>三、配置</h2><h3 id="1、配置文件"><a href="#1、配置文件" class="headerlink" title="1、配置文件"></a>1、配置文件</h3><p>（1）系统配置</p>
<p>C:\Program Files\Git\etc\gitconfig</p>
<p>针对所有用户的。</p>
<div class="highlight-container" data-rel="Plaintext"><figure class="iseeu highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git config --system   键    值</span><br></pre></td></tr></table></figure></div>



<p>（2）全局配置</p>
<p>C:\Users\HS\ .gitconfig</p>
<p>只针对当前用户的。</p>
<div class="highlight-container" data-rel="Plaintext"><figure class="iseeu highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git config --global   键    值</span><br></pre></td></tr></table></figure></div>



<p>（3）仓库配置</p>
<p>只针对当前仓库有效。</p>
<p>D:\git-work\repository01\ .git\config</p>
<div class="highlight-container" data-rel="Plaintext"><figure class="iseeu highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git config   键    值</span><br></pre></td></tr></table></figure></div>



<h3 id="2、配置用户名和邮箱"><a href="#2、配置用户名和邮箱" class="headerlink" title="2、配置用户名和邮箱"></a>2、配置用户名和邮箱</h3><p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020115438280.png"
                      alt="image-20211020115438280"
                ></p>
<h2 id="四、工作原理"><a href="#四、工作原理" class="headerlink" title="四、工作原理"></a>四、工作原理</h2><p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="https://www.runoob.com/wp-content/uploads/2015/02/1352126739_7909.jpg"
                      alt="img"
                ></p>
<h3 id="1、名词概念"><a href="#1、名词概念" class="headerlink" title="1、名词概念"></a>1、名词概念</h3><p><strong>工作区</strong>：编写源代码的保存目录。</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020121429891.png"
                      alt="image-20211020121429891"
                ></p>
<p><strong>暂存区</strong>：英文叫 stage 或 index。将源代码添加到暂存区。</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020121604798.png"
                      alt="image-20211020121604798"
                ></p>
<p><strong>本地仓库</strong>：将暂存区的代码同步到本地仓库。</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020121745369.png"
                      alt="image-20211020121745369"
                ></p>
<p><strong>远程仓库</strong>：将本地仓库的代码推送到远程仓库存储。</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020121919977.png"
                      alt="image-20211020121919977"
                ></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020122155095.png"
                      alt="image-20211020122155095"
                ></p>
<p>可以使用gitlab&#x3D;&#x3D;搭建公司内部的远程仓库。</p>
<h3 id="2、工作原理"><a href="#2、工作原理" class="headerlink" title="2、工作原理"></a>2、工作原理</h3><p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="https://www.runoob.com/wp-content/uploads/2015/02/git-command.jpg"
                      alt="img"
                ></p>
<h2 id="五、创建本地仓库"><a href="#五、创建本地仓库" class="headerlink" title="五、创建本地仓库"></a>五、创建本地仓库</h2><h3 id="1、初始化本地仓库"><a href="#1、初始化本地仓库" class="headerlink" title="1、初始化本地仓库"></a>1、初始化本地仓库</h3><p>（1）选择某个目录作为你的本地仓库</p>
<p>比如D:\git-work\hs01</p>
<p>hs01是工作区的根目录</p>
<p>（2）在该目录下打开git bash</p>
<p> <strong>git  init</strong></p>
<p>生成一个.git目录，也就是本地仓库。</p>
<p>.git目录下有一个index文件，这是暂存区。</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020144109544.png"
                      alt="image-20211020144109544"
                ></p>
<h3 id="2、通过克隆远程仓库创建本地仓库"><a href="#2、通过克隆远程仓库创建本地仓库" class="headerlink" title="2、通过克隆远程仓库创建本地仓库"></a>2、通过克隆远程仓库创建本地仓库</h3><p>（1）选择父目录</p>
<p>（2）打开git  bash</p>
<p>执行命令：<strong>git  clone  远程仓库的地址</strong></p>
<p>gitee：</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020144949632.png"
                      alt="image-20211020144949632"
                ></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020144732059.png"
                      alt="image-20211020144732059"
                ></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020144921356.png"
                      alt="image-20211020144921356"
                ></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020144934778.png"
                      alt="image-20211020144934778"
                ></p>
<p>gitHub：</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020145123122.png"
                      alt="image-20211020145123122"
                ></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020145147919.png"
                      alt="image-20211020145147919"
                ></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020145203368.png"
                      alt="image-20211020145203368"
                ></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020145218580.png"
                      alt="image-20211020145218580"
                ></p>
<h2 id="六、Linux命令"><a href="#六、Linux命令" class="headerlink" title="六、Linux命令"></a>六、Linux命令</h2><h3 id="1、Linux命令和Windows的dos命令类似。"><a href="#1、Linux命令和Windows的dos命令类似。" class="headerlink" title="1、Linux命令和Windows的dos命令类似。"></a>1、Linux命令和Windows的dos命令类似。</h3><h3 id="2、git-bash支持Linux命令"><a href="#2、git-bash支持Linux命令" class="headerlink" title="2、git  bash支持Linux命令"></a>2、git  bash支持Linux命令</h3><h3 id="3、常用Linux命令"><a href="#3、常用Linux命令" class="headerlink" title="3、常用Linux命令"></a>3、常用Linux命令</h3><p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/YPM7CGQLW5%5BO%5DEYZ%7DF55M%5B6.jpg"
                      alt="img"
                ></p>
<p>cp  复制</p>
<h2 id="七、git基本操作"><a href="#七、git基本操作" class="headerlink" title="七、git基本操作"></a>七、git基本操作</h2><p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="https://www.runoob.com/wp-content/uploads/2015/02/git-command.jpg"
                      alt="img"
                ></p>
<h3 id="1、将工作区的文件添加到暂存区"><a href="#1、将工作区的文件添加到暂存区" class="headerlink" title="1、将工作区的文件添加到暂存区"></a>1、将工作区的文件添加到暂存区</h3><p><strong>git   add    文件名</strong></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020152759379.png"
                      alt="image-20211020152759379"
                ></p>
<p>批量添加：<strong>git   add   .</strong></p>
<h3 id="2、从暂存区将文件提交到本地仓库"><a href="#2、从暂存区将文件提交到本地仓库" class="headerlink" title="2、从暂存区将文件提交到本地仓库"></a>2、从暂存区将文件提交到本地仓库</h3><p><strong>git  commit    文件名   -m   “提交描述”</strong></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020152947144.png"
                      alt="image-20211020152947144"
                ></p>
<p>批量提交：<strong>git   commit     -m   “提交描述”</strong></p>
<h3 id="3、查看提交日志"><a href="#3、查看提交日志" class="headerlink" title="3、查看提交日志"></a>3、查看提交日志</h3><p><strong>git   log</strong></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020154334985.png"
                      alt="image-20211020154334985"
                ></p>
<h3 id="4、删除仓库的文件"><a href="#4、删除仓库的文件" class="headerlink" title="4、删除仓库的文件"></a>4、删除仓库的文件</h3><p>git  rm   -r   文件或目录</p>
<p>git  commit  -m   ‘删除日志’</p>
<p><strong>一般不做删除操作，比较危险。</strong></p>
<h2 id="八、文件状态"><a href="#八、文件状态" class="headerlink" title="八、文件状态"></a>八、文件状态</h2><p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="https://www.runoob.com/wp-content/uploads/2015/02/git-command.jpg"
                      alt="img"
                ></p>
<p>查看文件状态：<strong>git  status</strong></p>
<h3 id="1、Untracked未跟踪状态"><a href="#1、Untracked未跟踪状态" class="headerlink" title="1、Untracked未跟踪状态"></a>1、Untracked未跟踪状态</h3><p>我们在工作区新建一个文件，没有添加暂存区，也没有入库。</p>
<p>git不能对这个文件进行版本控制。</p>
<p>显示红色。</p>
<h3 id="2、Staged暂存状态"><a href="#2、Staged暂存状态" class="headerlink" title="2、Staged暂存状态"></a>2、Staged暂存状态</h3><p>将文件添加到暂存区，还没有入库。</p>
<p>显示绿色。</p>
<h3 id="3、unmodify已入库，未修改状态"><a href="#3、unmodify已入库，未修改状态" class="headerlink" title="3、unmodify已入库，未修改状态"></a>3、unmodify已入库，未修改状态</h3><p>提交到本地仓库的文件，已入库。入库后，没有再修改。</p>
<p>这些文件可以被git进行版本控制管理。</p>
<p>没有显示。</p>
<h3 id="4、modified已入库，已修改状态"><a href="#4、modified已入库，已修改状态" class="headerlink" title="4、modified已入库，已修改状态"></a>4、modified已入库，已修改状态</h3><p>提交到本地仓库的文件，已入库。入库后，又修改了。</p>
<p>显示红色。</p>
<h3 id="5、merge合并状态"><a href="#5、merge合并状态" class="headerlink" title="5、merge合并状态"></a>5、merge合并状态</h3><p>两个分支的内容进行合并，合并的文件处于合并状态。</p>
<h2 id="九、远程仓库"><a href="#九、远程仓库" class="headerlink" title="九、远程仓库"></a>九、远程仓库</h2><h3 id="1、gitee码云"><a href="#1、gitee码云" class="headerlink" title="1、gitee码云"></a>1、gitee码云</h3><p>（1）官网地址：<a class="link"   target="_blank" rel="noopener" href="https://gitee.com/" >https://gitee.com/<i class="fas fa-external-link-alt"></i></a></p>
<p>（2）注册账户</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020161426891.png"
                      alt="image-20211020161426891"
                ></p>
<p>（3）登录</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020161521632.png"
                      alt="image-20211020161521632"
                ></p>
<p>（4）搜索开源项目</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020161635368.png"
                      alt="image-20211020161635368"
                ></p>
<h3 id="2、github"><a href="#2、github" class="headerlink" title="2、github"></a>2、github</h3><p>（1）官网地址：<a class="link"   target="_blank" rel="noopener" href="https://github.com/" >https://github.com/<i class="fas fa-external-link-alt"></i></a></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020162042686.png"
                      alt="image-20211020162042686"
                ></p>
<p>（2）注册账户</p>
<p>（3）登录</p>
<p>（4）搜索开源项目</p>
<h3 id="3、私服（gitlab-x3D-x3D-）"><a href="#3、私服（gitlab-x3D-x3D-）" class="headerlink" title="3、私服（gitlab&#x3D;&#x3D;）"></a>3、私服（gitlab&#x3D;&#x3D;）</h3><h2 id="十、Gitee码云"><a href="#十、Gitee码云" class="headerlink" title="十、Gitee码云"></a>十、Gitee码云</h2><h3 id="1、新建仓库"><a href="#1、新建仓库" class="headerlink" title="1、新建仓库"></a>1、新建仓库</h3><p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020162535434.png"
                      alt="image-20211020162535434"
                ></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020162605633.png"
                      alt="image-20211020162605633"
                ></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020162637457.png"
                      alt="image-20211020162637457"
                ></p>
<h3 id="2、克隆远程仓库"><a href="#2、克隆远程仓库" class="headerlink" title="2、克隆远程仓库"></a>2、克隆远程仓库</h3><p><strong>git  clone  仓库地址</strong></p>
<p>仓库地址有两种：https  和 ssh</p>
<p><a class="link"   target="_blank" rel="noopener" href="https://gitee.com/areytonghua/java02.git" >https://gitee.com/areytonghua/java02.git<i class="fas fa-external-link-alt"></i></a></p>
<p><a class="link"   href="mailto:&#103;&#105;&#x74;&#x40;&#x67;&#105;&#x74;&#101;&#101;&#46;&#x63;&#111;&#109;" >&#103;&#105;&#x74;&#x40;&#x67;&#105;&#x74;&#101;&#101;&#46;&#x63;&#111;&#109;<i class="fas fa-external-link-alt"></i></a>:areytonghua&#x2F;java02.git</p>
<p>https  ：有时需要输入用户名和密码进行验证。</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020163141234.png"
                      alt="image-20211020163141234"
                ></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020163227779.png"
                      alt="image-20211020163227779"
                ></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020163255385.png"
                      alt="image-20211020163255385"
                ></p>
<h3 id="3、推送文件到远程仓库"><a href="#3、推送文件到远程仓库" class="headerlink" title="3、推送文件到远程仓库"></a>3、推送文件到远程仓库</h3><p><strong>git  push    地址或别名</strong></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020163644432.png"
                      alt="image-20211020163644432"
                ></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020163736463.png"
                      alt="image-20211020163736463"
                ></p>
<h3 id="4、从远程仓库拉取文件"><a href="#4、从远程仓库拉取文件" class="headerlink" title="4、从远程仓库拉取文件"></a>4、从远程仓库拉取文件</h3><p><strong>git   pull   地址或别名   本地分支名：远程分支名</strong></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020164209852.png"
                      alt="image-20211020164209852"
                ></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020164148150.png"
                      alt="image-20211020164148150"
                ></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020164223074.png"
                      alt="image-20211020164223074"
                ></p>
<p><strong>注意：</strong></p>
<p>拉取和推送，本地仓库和远程建立<strong>关联</strong>，并且本地工作区的文件必须全部完成<strong>入库</strong>。</p>
<p>拉取和推送，自己起的别名需要指定分支。</p>
<h3 id="5、管理连接"><a href="#5、管理连接" class="headerlink" title="5、管理连接"></a>5、管理连接</h3><p>（1）查看所有连接信息</p>
<p>git   remote   -v</p>
<p>（2）给连接起别名</p>
<p>git   remote  add   别名  地址</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020164722949.png"
                      alt="image-20211020164722949"
                ></p>
<h3 id="6、Pull和Fetch"><a href="#6、Pull和Fetch" class="headerlink" title="6、Pull和Fetch"></a>6、Pull和Fetch</h3><p>（1）fetch和pull</p>
<p>Fetch：从远程仓库拉取代码。</p>
<p>Merge：将远程仓库代码和本地仓库合并。</p>
<p>Pull：  从远程仓库拉取代码，然后和本地仓库代码合并。</p>
<p>Pull&#x3D;Fetch+Merge</p>
<p>（2）注意：合并可能会冲突。</p>
<p>解决：处理冲突，然后提交（所有）。</p>
<p>推送的正确流程：</p>
<p>先拉，合并冲突，提交，再推。</p>
<h3 id="7、SSH"><a href="#7、SSH" class="headerlink" title="7、SSH"></a>7、SSH</h3><p>（1）连接形式</p>
<p>HTTPs ：使用用户名和密码验证。</p>
<p>SSH   ： 使用公钥私钥验证。</p>
<p>（2）本地创建公钥私钥</p>
<p>切换到当前用户目录下：C:\Users\HS</p>
<p>然后创建.ssh目录</p>
<p>切换到.ssh目录下</p>
<p>执行命令：ssh-keygen -t rsa -C    “邮箱”</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020173616407.png"
                      alt="image-20211020173616407"
                ></p>
<p>（3）远程仓库配置公钥</p>
<p>打开本地公钥文件：复制</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020173827156.png"
                      alt="image-20211020173827156"
                ></p>
<p>再码云上，选择设置</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020173902512.png"
                      alt="image-20211020173902512"
                ></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020173933277.png"
                      alt="image-20211020173933277"
                ></p>
<p>添加公钥</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020174039637.png"
                      alt="image-20211020174039637"
                ></p>
<p>输入码云的密码</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020174114788.png"
                      alt="image-20211020174114788"
                ></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020174131246.png"
                      alt="image-20211020174131246"
                ></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211020174225749.png"
                      alt="image-20211020174225749"
                ></p>
<p><strong>仓库的公钥配置和用户公钥配置的区别：</strong></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211021164940820.png"
                      alt="image-20211021164940820"
                ></p>
<p>仓库的公钥：默认只读，用于克隆和拉取，不能推送。只用于当前仓库。如果需要写，勾选写操作。</p>
<p>用户公钥：默认可以读写，用于克隆和拉取，也能推送。用于当前用户的所有仓库。</p>
<p>（4）测试</p>
<p>执行clone、push、pull操作</p>
<p>测试结果：</p>
<p>git  2.33.1          rsa      gitee     ssh连接失败</p>
<p>git  历史版本     rsa      gitee     ssh连接成功</p>
<p>git  2.33.1     rsa      github   ssh连接成功</p>
<p>解决方案：</p>
<p>git  历史版本     rsa      gitee     ssh连接成功</p>
<p>git  2.33.1          ed25519    gitee     ssh连接成功</p>
<h2 id="十一、GitHub"><a href="#十一、GitHub" class="headerlink" title="十一、GitHub"></a>十一、GitHub</h2><p>和gitee操作一样，使用ssh。</p>
<p>60%以上使用github。当然，也有不少开发公司使用的码云。还有很多公司自己使用gitlab搭建远程仓库服务器。</p>
<h2 id="十二、分支管理"><a href="#十二、分支管理" class="headerlink" title="十二、分支管理"></a>十二、分支管理</h2><h3 id="1、分支作用"><a href="#1、分支作用" class="headerlink" title="1、分支作用"></a>1、分支作用</h3><p>几乎每一种版本控制系统都以某种形式支持分支。使用分支意味着你可以从开发主线上分离开来，然后在不影响主线的同时继续工作。</p>
<p>有人把 Git 的分支模型称为<strong>必杀技特性</strong>，而正是因为它，将 <strong>Git</strong> 从版本控制系统家族里区分出来。</p>
<h3 id="2、创建分支"><a href="#2、创建分支" class="headerlink" title="2、创建分支"></a>2、创建分支</h3><p>git  branch  </p>
<p>查看分支</p>
<p><strong>git   branch   新分支名</strong></p>
<p>每个仓库创建时，都会有一个主分支master。</p>
<h3 id="3、切换分支"><a href="#3、切换分支" class="headerlink" title="3、切换分支"></a>3、切换分支</h3><p>（1）第一种</p>
<p>&#x2F;&#x2F;切换到指定分支</p>
<p><strong>git  checkout   分支名</strong></p>
<p>&#x2F;&#x2F;新建分支，并切换到新分支</p>
<p><strong>git  checkout   -b   新分支</strong></p>
<p>（2）第二种（大概从2.3.0）</p>
<p>git  switch   分支名</p>
<h3 id="4、合并分支"><a href="#4、合并分支" class="headerlink" title="4、合并分支"></a>4、合并分支</h3><p>尽量保证两个分支的工作区文件处于unmodify。</p>
<p>（1）合并分支</p>
<p><strong>git  merge</strong></p>
<p>（2）冲突解决处理（注意！！！！！！！！！）</p>
<p>合并出现冲突，显示（main|merging）.</p>
<p>需要先解决冲突，才能再main分支中做其他操作。</p>
<p>第一步，打开所有冲突文件，将文件中的冲突标记去除，然后修改内容为你想要的结果，保存。</p>
<p>第二步，执行git  add  .</p>
<p>第三步，执行git  commit  -m  “”</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211021105904580.png"
                      alt="image-20211021105904580"
                ></p>
<h3 id="5、删除分支"><a href="#5、删除分支" class="headerlink" title="5、删除分支"></a>5、删除分支</h3><p>git   branch   -d  分支名</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20221212110234087.png"
                      alt="image-20221212110234087"
                ></p>
<h3 id="6、比对文件"><a href="#6、比对文件" class="headerlink" title="6、比对文件"></a>6、比对文件</h3><p>（1）比对分支</p>
<p>git   diff   分支1  分支2   [选择比对的文件，没有比对所有文件]</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20221212110844286.png"
                      alt="image-20221212110844286"
                ></p>
<p>（2）比对版本</p>
<p>git   log  查看版本</p>
<p>git  diff   版本1   版本2</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20221212112134185.png"
                      alt="image-20221212112134185"
                ></p>
<h2 id="十三、忽略文件"><a href="#十三、忽略文件" class="headerlink" title="十三、忽略文件"></a>十三、忽略文件</h2><h3 id="1、作用"><a href="#1、作用" class="headerlink" title="1、作用"></a>1、作用</h3><p>我们可以指定哪些文件和目录不提交到仓库。</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20221212142835167.png"
                      alt="image-20221212142835167"
                ></p>
<h3 id="2、忽略文件"><a href="#2、忽略文件" class="headerlink" title="2、忽略文件"></a>2、忽略文件</h3><p>通过.gitignore指定需要忽略的文件和目录。</p>
<p>（1）全局忽略文件</p>
<p>–global  指定全局的.gitignore</p>
<p>git config –global core.excludesfile ~&#x2F;.gitignore</p>
<p>作用域：所有仓库</p>
<p>（2）局部忽略文件</p>
<p>将.gitignore放在仓库根目录下</p>
<p>作用域：当前仓库</p>
<h3 id="3、-gitignore文件"><a href="#3、-gitignore文件" class="headerlink" title="3、.gitignore文件"></a>3、.gitignore文件</h3><p>*.html   忽略所有.html文件</p>
<p>.idea      忽略所有.idea文件和目录</p>
<p>.idea&#x2F;    忽略所有.idea目录</p>
<p>&#x2F;.idea    忽略当前目录下的.idea,其他目录下的.idea不忽略</p>
<p>!.idea     不忽略.idea</p>
<h2 id="十四、idea集成git（全篇重点）"><a href="#十四、idea集成git（全篇重点）" class="headerlink" title="十四、idea集成git（全篇重点）"></a>十四、idea集成git（全篇重点）</h2><h3 id="1、本地安装git"><a href="#1、本地安装git" class="headerlink" title="1、本地安装git"></a>1、本地安装git</h3><h3 id="2、配置用户信息"><a href="#2、配置用户信息" class="headerlink" title="2、配置用户信息"></a>2、配置用户信息</h3><p>全局配置</p>
<p>user.name</p>
<p>user.email</p>
<h3 id="3、idea集成git"><a href="#3、idea集成git" class="headerlink" title="3、idea集成git"></a>3、idea集成git</h3><p>（1）再idea中配置git</p>
<p>C:\Program Files<strong>\Git\bin\git.exe</strong></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211021145504180.png"
                      alt="image-20211021145504180"
                ></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211021145617776.png"
                      alt="image-20211021145617776"
                ></p>
<p>记得保存</p>
<p>（2）配置远程仓库github</p>
<p>gitee需要安装插件，才能出现配置菜单。</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211021145925729.png"
                      alt="image-20211021145925729"
                ></p>
<p>配置：</p>
<p>老版idea界面2020.1</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211021160218411.png"
                      alt="image-20211021160218411"
                ></p>
<p>新版idea界面2020.2</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211021150038236.png"
                      alt="image-20211021150038236"
                ></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211021150116287.png"
                      alt="image-20211021150116287"
                ></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211021150155281.png"
                      alt="image-20211021150155281"
                ></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211021150249557.png"
                      alt="image-20211021150249557"
                ></p>
<p>最后：</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211021150601859.png"
                      alt="image-20211021150601859"
                ></p>
<h3 id="4、架构师操作"><a href="#4、架构师操作" class="headerlink" title="4、架构师操作"></a>4、架构师操作</h3><p>（1）创建项目，搭好开发框架。</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211021151556488.png"
                      alt="image-20211021151556488"
                ></p>
<p>（2）一键上传远程仓库</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20221212173251440.png"
                      alt="image-20221212173251440"
                ></p>
<p>建立连接：</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20221212173320495.png"
                      alt="image-20221212173320495"
                ></p>
<p>选择提交的文件：</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20221212173351460.png"
                      alt="image-20221212173351460"
                ></p>
<p>add，自动创建本地库和远程库，并提交选择的文件。</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20221212173509914.png"
                      alt="image-20221212173509914"
                ></p>
<h3 id="5、开发人员操作"><a href="#5、开发人员操作" class="headerlink" title="5、开发人员操作"></a>5、开发人员操作</h3><p>Git工具条：</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/F%60U_ED%5BSK_2V@%5B%7D9OTG4HA2.png"
                      alt="img"
                ></p>
<p>（1）克隆仓库</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211021170202917.png"
                      alt="image-20211021170202917"
                ></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211021170239202.png"
                      alt="image-20211021170239202"
                ></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211021170328132.png"
                      alt="image-20211021170328132"
                ></p>
<p>（2）本地仓库操作</p>
<p>编写源代码</p>
<p>add暂存区</p>
<p>commit本地库</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211021171010147.png"
                      alt="image-20211021171010147"
                ></p>
<p>（3）推送代码至远程服务器</p>
<p>push</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211021171221538.png"
                      alt="image-20211021171221538"
                ></p>
<p>（4）拉取代码</p>
<p>pull</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211021171333855.png"
                      alt="image-20211021171333855"
                ></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211021171440049.png"
                      alt="image-20211021171440049"
                ></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211021171519137.png"
                      alt="image-20211021171519137"
                ></p>
<p>（5）命令行操作</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20211021171731652.png"
                      alt="image-20211021171731652"
                ></p>
<p>（6）版本回退：</p>
<p>命令行：</p>
<div class="highlight-container" data-rel="Plaintext"><figure class="iseeu highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">1. 查看版本号：git log，也可以上代码托管网页上查看history，找到需要回滚的目标版本号</span><br><span class="line">2. 使用“git reset --hard 目标版本号”命令将版本回退</span><br><span class="line">3. 使用“git push -f”提交更改，此时如果用“git push”会报错，因为我们本地库HEAD指向的版本比远程库的要旧，用“git push -f”强制推上去。</span><br></pre></td></tr></table></figure></div>

<p>idea：</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20221213105206483.png"
                      alt="image-20221213105206483"
                ></p>
<p>（7）比对文件</p>
<p>安装插件：</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20221213113731510.png"
                      alt="image-20221213113731510"
                ></p>
<p>比对：</p>
<p>按照版本比对或者按照分支比对</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20221213113835618.png"
                      alt="image-20221213113835618"
                ></p>
<h2 id="十五、hexo搭建gitee个人博客"><a href="#十五、hexo搭建gitee个人博客" class="headerlink" title="十五、hexo搭建gitee个人博客"></a>十五、hexo搭建gitee个人博客</h2><h3 id="1、安装git和nodeJs"><a href="#1、安装git和nodeJs" class="headerlink" title="1、安装git和nodeJs"></a>1、安装git和nodeJs</h3><p>（1）安装git</p>
<p>（2）安装nodeJs</p>
<p>下载地址：</p>
<p><a class="link"   target="_blank" rel="noopener" href="https://nodejs.org/en/" >https://nodejs.org/en/<i class="fas fa-external-link-alt"></i></a></p>
<h3 id="2、安装hexo"><a href="#2、安装hexo" class="headerlink" title="2、安装hexo"></a>2、安装hexo</h3><p>npm install -g hexo-cli</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20221213143236248.png"
                      alt="image-20221213143236248"
                ></p>
<h3 id="3、创建博客项目"><a href="#3、创建博客项目" class="headerlink" title="3、创建博客项目"></a>3、创建博客项目</h3><p>（1）在磁盘中选择一个存储目录，初始化博客项目。</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20221213143225362.png"
                      alt="image-20221213143225362"
                ></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20221213143311633.png"
                      alt="image-20221213143311633"
                ></p>
<p>（2）进入项目根目录，安装依赖</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20221213143431963.png"
                      alt="image-20221213143431963"
                ></p>
<p>（3）启动服务</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20221213144329341.png"
                      alt="image-20221213144329341"
                ></p>
<p>（4）访问站点</p>
<p><a class="link"   target="_blank" rel="noopener" href="http://localhost:4000/" >http://localhost:4000/<i class="fas fa-external-link-alt"></i></a></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/Git%E4%BD%BF%E7%94%A8.assets/image-20221213144358254.png"
                      alt="image-20221213144358254"
                ></p>

            </div>

            
                <div class="post-copyright-info">
                    <div class="article-copyright-info-container">
    <ul>
        <li>Post title：</li>
        <li>Post author：Sun-dingyang</li>
        <li>Create time：2022-12-13 15:59:18</li>
        <li>
            Post link：https://redefine.evanluo.top/2022/12/13/Git使用/
        </li>
        <li>
            Copyright Notice：All articles in this blog are licensed under <a class="license" target="_blank" rel="noopener" href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh">BY-NC-SA</a> unless stating additionally.
        </li>
    </ul>
</div>

                </div>
            

            

            
                <div class="article-nav">
                    
                        <div class="article-prev">
                            <a class="prev"
                            rel="prev"
                            href="/2022/12/13/test/"
                            >
                                <span class="left arrow-icon flex-center">
                                <i class="fas fa-chevron-left"></i>
                                </span>
                                <span class="title flex-center">
                                    <span class="post-nav-title-item"></span>
                                    <span class="post-nav-item">Prev posts</span>
                                </span>
                            </a>
                        </div>
                    
                    
                        <div class="article-next">
                            <a class="next"
                            rel="next"
                            href="/2022/12/13/hello-world/"
                            >
                                <span class="title flex-center">
                                    <span class="post-nav-title-item">Hello World</span>
                                    <span class="post-nav-item">Next posts</span>
                                </span>
                                <span class="right arrow-icon flex-center">
                                <i class="fas fa-chevron-right"></i>
                                </span>
                            </a>
                        </div>
                    
                </div>
            

            
        </div>

        
            <div class="toc-content-container">
                <div class="post-toc-wrap">
    <div class="post-toc">
        <div style="font-size: 1.3rem;margin-top: 0; margin-bottom: 0.8rem; transition-duration: 0.1s;"><i class="fa-solid fa-list"></i> <strong>Contents</strong></div>
        <ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#Git%E4%BD%BF%E7%94%A8"><span class="nav-text">Git使用</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E4%B8%80%E3%80%81git%E4%BB%8B%E7%BB%8D"><span class="nav-text">一、git介绍</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1%E3%80%81%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6%E5%B7%A5%E5%85%B7"><span class="nav-text">1、版本控制工具</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2%E3%80%81git%E5%92%8Csvn"><span class="nav-text">2、git和svn</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E4%BA%8C%E3%80%81git%E5%AE%89%E8%A3%85"><span class="nav-text">二、git安装</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1%E3%80%81%E4%B8%8B%E8%BD%BD"><span class="nav-text">1、下载</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2%E3%80%81%E5%AE%89%E8%A3%85"><span class="nav-text">2、安装</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3%E3%80%81%E6%B5%8B%E8%AF%95"><span class="nav-text">3、测试</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E4%B8%89%E3%80%81%E9%85%8D%E7%BD%AE"><span class="nav-text">三、配置</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1%E3%80%81%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6"><span class="nav-text">1、配置文件</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2%E3%80%81%E9%85%8D%E7%BD%AE%E7%94%A8%E6%88%B7%E5%90%8D%E5%92%8C%E9%82%AE%E7%AE%B1"><span class="nav-text">2、配置用户名和邮箱</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%9B%9B%E3%80%81%E5%B7%A5%E4%BD%9C%E5%8E%9F%E7%90%86"><span class="nav-text">四、工作原理</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1%E3%80%81%E5%90%8D%E8%AF%8D%E6%A6%82%E5%BF%B5"><span class="nav-text">1、名词概念</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2%E3%80%81%E5%B7%A5%E4%BD%9C%E5%8E%9F%E7%90%86"><span class="nav-text">2、工作原理</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E4%BA%94%E3%80%81%E5%88%9B%E5%BB%BA%E6%9C%AC%E5%9C%B0%E4%BB%93%E5%BA%93"><span class="nav-text">五、创建本地仓库</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1%E3%80%81%E5%88%9D%E5%A7%8B%E5%8C%96%E6%9C%AC%E5%9C%B0%E4%BB%93%E5%BA%93"><span class="nav-text">1、初始化本地仓库</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2%E3%80%81%E9%80%9A%E8%BF%87%E5%85%8B%E9%9A%86%E8%BF%9C%E7%A8%8B%E4%BB%93%E5%BA%93%E5%88%9B%E5%BB%BA%E6%9C%AC%E5%9C%B0%E4%BB%93%E5%BA%93"><span class="nav-text">2、通过克隆远程仓库创建本地仓库</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%85%AD%E3%80%81Linux%E5%91%BD%E4%BB%A4"><span class="nav-text">六、Linux命令</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1%E3%80%81Linux%E5%91%BD%E4%BB%A4%E5%92%8CWindows%E7%9A%84dos%E5%91%BD%E4%BB%A4%E7%B1%BB%E4%BC%BC%E3%80%82"><span class="nav-text">1、Linux命令和Windows的dos命令类似。</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2%E3%80%81git-bash%E6%94%AF%E6%8C%81Linux%E5%91%BD%E4%BB%A4"><span class="nav-text">2、git  bash支持Linux命令</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3%E3%80%81%E5%B8%B8%E7%94%A8Linux%E5%91%BD%E4%BB%A4"><span class="nav-text">3、常用Linux命令</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E4%B8%83%E3%80%81git%E5%9F%BA%E6%9C%AC%E6%93%8D%E4%BD%9C"><span class="nav-text">七、git基本操作</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1%E3%80%81%E5%B0%86%E5%B7%A5%E4%BD%9C%E5%8C%BA%E7%9A%84%E6%96%87%E4%BB%B6%E6%B7%BB%E5%8A%A0%E5%88%B0%E6%9A%82%E5%AD%98%E5%8C%BA"><span class="nav-text">1、将工作区的文件添加到暂存区</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2%E3%80%81%E4%BB%8E%E6%9A%82%E5%AD%98%E5%8C%BA%E5%B0%86%E6%96%87%E4%BB%B6%E6%8F%90%E4%BA%A4%E5%88%B0%E6%9C%AC%E5%9C%B0%E4%BB%93%E5%BA%93"><span class="nav-text">2、从暂存区将文件提交到本地仓库</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3%E3%80%81%E6%9F%A5%E7%9C%8B%E6%8F%90%E4%BA%A4%E6%97%A5%E5%BF%97"><span class="nav-text">3、查看提交日志</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#4%E3%80%81%E5%88%A0%E9%99%A4%E4%BB%93%E5%BA%93%E7%9A%84%E6%96%87%E4%BB%B6"><span class="nav-text">4、删除仓库的文件</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%85%AB%E3%80%81%E6%96%87%E4%BB%B6%E7%8A%B6%E6%80%81"><span class="nav-text">八、文件状态</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1%E3%80%81Untracked%E6%9C%AA%E8%B7%9F%E8%B8%AA%E7%8A%B6%E6%80%81"><span class="nav-text">1、Untracked未跟踪状态</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2%E3%80%81Staged%E6%9A%82%E5%AD%98%E7%8A%B6%E6%80%81"><span class="nav-text">2、Staged暂存状态</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3%E3%80%81unmodify%E5%B7%B2%E5%85%A5%E5%BA%93%EF%BC%8C%E6%9C%AA%E4%BF%AE%E6%94%B9%E7%8A%B6%E6%80%81"><span class="nav-text">3、unmodify已入库，未修改状态</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#4%E3%80%81modified%E5%B7%B2%E5%85%A5%E5%BA%93%EF%BC%8C%E5%B7%B2%E4%BF%AE%E6%94%B9%E7%8A%B6%E6%80%81"><span class="nav-text">4、modified已入库，已修改状态</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#5%E3%80%81merge%E5%90%88%E5%B9%B6%E7%8A%B6%E6%80%81"><span class="nav-text">5、merge合并状态</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E4%B9%9D%E3%80%81%E8%BF%9C%E7%A8%8B%E4%BB%93%E5%BA%93"><span class="nav-text">九、远程仓库</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1%E3%80%81gitee%E7%A0%81%E4%BA%91"><span class="nav-text">1、gitee码云</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2%E3%80%81github"><span class="nav-text">2、github</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3%E3%80%81%E7%A7%81%E6%9C%8D%EF%BC%88gitlab-x3D-x3D-%EF%BC%89"><span class="nav-text">3、私服（gitlab&#x3D;&#x3D;）</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%8D%81%E3%80%81Gitee%E7%A0%81%E4%BA%91"><span class="nav-text">十、Gitee码云</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1%E3%80%81%E6%96%B0%E5%BB%BA%E4%BB%93%E5%BA%93"><span class="nav-text">1、新建仓库</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2%E3%80%81%E5%85%8B%E9%9A%86%E8%BF%9C%E7%A8%8B%E4%BB%93%E5%BA%93"><span class="nav-text">2、克隆远程仓库</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3%E3%80%81%E6%8E%A8%E9%80%81%E6%96%87%E4%BB%B6%E5%88%B0%E8%BF%9C%E7%A8%8B%E4%BB%93%E5%BA%93"><span class="nav-text">3、推送文件到远程仓库</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#4%E3%80%81%E4%BB%8E%E8%BF%9C%E7%A8%8B%E4%BB%93%E5%BA%93%E6%8B%89%E5%8F%96%E6%96%87%E4%BB%B6"><span class="nav-text">4、从远程仓库拉取文件</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#5%E3%80%81%E7%AE%A1%E7%90%86%E8%BF%9E%E6%8E%A5"><span class="nav-text">5、管理连接</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#6%E3%80%81Pull%E5%92%8CFetch"><span class="nav-text">6、Pull和Fetch</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#7%E3%80%81SSH"><span class="nav-text">7、SSH</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%8D%81%E4%B8%80%E3%80%81GitHub"><span class="nav-text">十一、GitHub</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%8D%81%E4%BA%8C%E3%80%81%E5%88%86%E6%94%AF%E7%AE%A1%E7%90%86"><span class="nav-text">十二、分支管理</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1%E3%80%81%E5%88%86%E6%94%AF%E4%BD%9C%E7%94%A8"><span class="nav-text">1、分支作用</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2%E3%80%81%E5%88%9B%E5%BB%BA%E5%88%86%E6%94%AF"><span class="nav-text">2、创建分支</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3%E3%80%81%E5%88%87%E6%8D%A2%E5%88%86%E6%94%AF"><span class="nav-text">3、切换分支</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#4%E3%80%81%E5%90%88%E5%B9%B6%E5%88%86%E6%94%AF"><span class="nav-text">4、合并分支</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#5%E3%80%81%E5%88%A0%E9%99%A4%E5%88%86%E6%94%AF"><span class="nav-text">5、删除分支</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#6%E3%80%81%E6%AF%94%E5%AF%B9%E6%96%87%E4%BB%B6"><span class="nav-text">6、比对文件</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%8D%81%E4%B8%89%E3%80%81%E5%BF%BD%E7%95%A5%E6%96%87%E4%BB%B6"><span class="nav-text">十三、忽略文件</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1%E3%80%81%E4%BD%9C%E7%94%A8"><span class="nav-text">1、作用</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2%E3%80%81%E5%BF%BD%E7%95%A5%E6%96%87%E4%BB%B6"><span class="nav-text">2、忽略文件</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3%E3%80%81-gitignore%E6%96%87%E4%BB%B6"><span class="nav-text">3、.gitignore文件</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%8D%81%E5%9B%9B%E3%80%81idea%E9%9B%86%E6%88%90git%EF%BC%88%E5%85%A8%E7%AF%87%E9%87%8D%E7%82%B9%EF%BC%89"><span class="nav-text">十四、idea集成git（全篇重点）</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1%E3%80%81%E6%9C%AC%E5%9C%B0%E5%AE%89%E8%A3%85git"><span class="nav-text">1、本地安装git</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2%E3%80%81%E9%85%8D%E7%BD%AE%E7%94%A8%E6%88%B7%E4%BF%A1%E6%81%AF"><span class="nav-text">2、配置用户信息</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3%E3%80%81idea%E9%9B%86%E6%88%90git"><span class="nav-text">3、idea集成git</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#4%E3%80%81%E6%9E%B6%E6%9E%84%E5%B8%88%E6%93%8D%E4%BD%9C"><span class="nav-text">4、架构师操作</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#5%E3%80%81%E5%BC%80%E5%8F%91%E4%BA%BA%E5%91%98%E6%93%8D%E4%BD%9C"><span class="nav-text">5、开发人员操作</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%8D%81%E4%BA%94%E3%80%81hexo%E6%90%AD%E5%BB%BAgitee%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A2"><span class="nav-text">十五、hexo搭建gitee个人博客</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1%E3%80%81%E5%AE%89%E8%A3%85git%E5%92%8CnodeJs"><span class="nav-text">1、安装git和nodeJs</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2%E3%80%81%E5%AE%89%E8%A3%85hexo"><span class="nav-text">2、安装hexo</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3%E3%80%81%E5%88%9B%E5%BB%BA%E5%8D%9A%E5%AE%A2%E9%A1%B9%E7%9B%AE"><span class="nav-text">3、创建博客项目</span></a></li></ol></li></ol></li></ol>
    </div>
</div>
            </div>
        
    </div>
</div>


                

            </div>



        </div>

        <div class="page-main-content-bottom">
            <footer class="footer">
    <div class="info-container">
        <div class="copyright-info info-item">
            &copy;
            
              <span>2020</span>
              -
            
            2023&nbsp;<i class="fas fa-heart icon-animate"></i>&nbsp;<a href="/">Sun-dingyang</a>
        </div>
        
            <script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
            <div class="website-count info-item">
                
                    <span id="busuanzi_container_site_uv">
                        Visitor Count&nbsp;<span id="busuanzi_value_site_uv"></span>&ensp;
                    </span>
                
                
                    <span id="busuanzi_container_site_pv">
                        Totalview&nbsp;<span id="busuanzi_value_site_pv"></span>
                    </span>
                
            </div>
        
        <div class="theme-info info-item">
            Powered by <a target="_blank" href="https://hexo.io">Hexo</a>&nbsp;|&nbsp;Theme&nbsp;<a class="theme-version" target="_blank" href="https://github.com/EvanNotFound/hexo-theme-redefine">Redefine v0.3.5</a>
        </div>
        
        
    </div>
    <link rel="stylesheet" href="//evan.beee.top/css/waline.css"/>
    <script src="//evan.beee.top/js/waline.js"></script>
    
<link rel="stylesheet" href="/css/regular.min.css">

</footer>
        </div>
    </div>

    
        <div class="post-tools">
            <div class="post-tools-container">
    <ul class="tools-list">
        <!-- TOC aside toggle -->
        
            <li class="tools-item page-aside-toggle">
                <i class="fa-duotone fa-outdent"></i>
            </li>
        

        <!-- go comment -->
        
    </ul>
</div>

        </div>
    

    <div class="right-bottom-side-tools">
        <div class="side-tools-container">
    <ul class="side-tools-list">
        <li class="tools-item tool-font-adjust-plus flex-center">
            <i class="fas fa-search-plus"></i>
        </li>

        <li class="tools-item tool-font-adjust-minus flex-center">
            <i class="fas fa-search-minus"></i>
        </li>

        <li class="tools-item tool-expand-width flex-center">
            <i class="fas fa-arrows-alt-h"></i>
        </li>

        <li class="tools-item tool-dark-light-toggle flex-center">
            <i class="fas fa-moon"></i>
        </li>

        <!-- rss -->
        

        
            <li class="tools-item tool-scroll-to-top flex-center">
                <i class="fas fa-arrow-up"></i>
            </li>
        

        <li class="tools-item tool-scroll-to-bottom flex-center">
            <i class="fas fa-arrow-down"></i>
        </li>
    </ul>

    <ul class="exposed-tools-list">
        <li class="tools-item tool-toggle-show flex-center">
            <i class="fas fa-cog fa-spin"></i>
        </li>
        
    </ul>
</div>

    </div>

    <div class="image-viewer-container">
    <img src="">
</div>


    

</main>




<script src="/js/utils.js"></script>

<script src="/js/main.js"></script>

<script src="/js/header-shrink.js"></script>

<script src="/js/back2top.js"></script>

<script src="/js/dark-light-toggle.js"></script>





    
<script src="/js/code-copy.js"></script>




    
<script src="/js/lazyload.js"></script>



<div class="post-scripts pjax">
    
        
<script src="/js/left-side-toggle.js"></script>

<script src="/js/libs/anime.min.js"></script>

<script src="/js/toc.js"></script>

    
</div>


    
<script src="/js/libs/pjax.min.js"></script>

<script>
    window.addEventListener('DOMContentLoaded', () => {
        window.pjax = new Pjax({
            selectors: [
                'head title',
                '.page-container',
                '.pjax'
            ],
            history: true,
            debug: false,
            cacheBust: false,
            timeout: 0,
            analytics: false,
            currentUrlFullReload: false,
            scrollRestoration: false,
            // scrollTo: true,
        });

        document.addEventListener('pjax:send', () => {
            REDEFINE.utils.pjaxProgressBarStart();
        });

        document.addEventListener('pjax:complete', () => {
            REDEFINE.utils.pjaxProgressBarEnd();
            window.pjax.executeScripts(document.querySelectorAll('script[data-pjax], .pjax script'));
            REDEFINE.refresh();
        });
    });
</script>



</body>
</html>
